﻿using AutoMapper;
using Tauren.Business.Entity.Const;

namespace Tauren.Business.Mapper
{
    public class ButtonProfile : Profile, ICommProfile
    {
        public ButtonProfile()
        {
            InitProfile();
        }

        /// <summary>
        /// 初始化Mapper
        /// </summary>
        public void InitProfile()
        {
            CreateMap<Entity.Model.Buttons, Entity.Output.Button_OutPut>();
            CreateMap<Entity.Model.ButtonRes, Entity.Output.ButtonRes_OutPut>();
            CreateMap<Entity.Input.ButtonRes_InPut, Entity.Model.ButtonRes>();
            CreateMap<Entity.Input.Button_Input, Entity.Model.Buttons>();
            CreateMap<Entity.Output.ButtonsTable, Entity.Output.Button_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
        }
    }
}
